#include <stdio.h>
#include <stdbool.h>

int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int WrongPos=0;
	int Circle=0;
	_Bool visited[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		visited[i]=false;
	}
	int tmp;
	for(int i=0;i<n;i++){
		if( visited[i] || i==a[i] ){
			continue;
		}
		Circle++;
		tmp=i;
		while( !visited[tmp] ){
			visited[tmp]=true;
			WrongPos++;
			tmp=a[tmp];
		}
	}

	//printf("WrongPos:%d\nCirCle:%d\n",WrongPos,Circle);
	if( a[0] == 0 ){
		printf("%d",Circle-1+WrongPos-1+2);
	}else{
		printf("%d",Circle-1+WrongPos-1);
	}
	return 0;
}
